<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|Georgia:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="HBase,Hadoop,高可用," />





  <link rel="alternate" href="/atom.xml" title="一本正经的小马" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/favicon1.ico?v=5.1.0" />






<meta name="description" content="本文主要介绍，在高可用（HA）Hadoop集群基础上搭建高可用（HA）的HBase集群。">
<meta name="keywords" content="HBase,Hadoop,高可用">
<meta property="og:type" content="article">
<meta property="og:title" content="HBase 高可用（HA）集群部署">
<meta property="og:url" content="https://www.hanbert.cn/2016/10/11/HBase-高可用（HA）集群部署/index.html">
<meta property="og:site_name" content="一本正经的小马">
<meta property="og:description" content="本文主要介绍，在高可用（HA）Hadoop集群基础上搭建高可用（HA）的HBase集群。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://img0.tuicool.com/FNJNvmm.png!web">
<meta property="og:image" content="http://img.blog.csdn.net/20161017234127072">
<meta property="og:image" content="http://img.blog.csdn.net/20161017234225172">
<meta property="og:updated_time" content="2017-04-10T01:45:28.341Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="HBase 高可用（HA）集群部署">
<meta name="twitter:description" content="本文主要介绍，在高可用（HA）Hadoop集群基础上搭建高可用（HA）的HBase集群。">
<meta name="twitter:image" content="http://img0.tuicool.com/FNJNvmm.png!web">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://www.hanbert.cn/2016/10/11/HBase-高可用（HA）集群部署/"/>





  <title> HBase 高可用（HA）集群部署 | 一本正经的小马 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  







  <script type="text/javascript">
    (function() {
      var hm = document.createElement("script");
      hm.src = "//tajs.qq.com/stats?sId=61405345";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">一本正经的小马</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">假装不正经</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-essay">
          <a href="/categories/随笔" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            随笔
          </a>
        </li>
      
        
        <li class="menu-item menu-item-study">
          <a href="/categories/学习" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-paper-plane"></i> <br />
            
            学习
          </a>
        </li>
      
        
        <li class="menu-item menu-item-other">
          <a href="/categories/杂记" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-list"></i> <br />
            
            杂记
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocapitalize="off" autocomplete="off" autocorrect="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://www.hanbert.cn/2016/10/11/HBase-高可用（HA）集群部署/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="小马">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar1.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一本正经的小马">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                HBase 高可用（HA）集群部署
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-10-11T09:12:33+08:00">
                2016-10-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/学习/" itemprop="url" rel="index">
                    <span itemprop="name">学习</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a class="cloud-tie-join-count" href="/2016/10/11/HBase-高可用（HA）集群部署/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count join-count" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2016/10/11/HBase-高可用（HA）集群部署/" class="leancloud_visitors" data-flag-title="HBase 高可用（HA）集群部署">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数 </span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>本文主要介绍，在高可用（HA）Hadoop集群基础上搭建高可用（HA）的HBase集群。</p>
<a id="more"></a>
<h3 id="一、HBase-是什么"><a href="#一、HBase-是什么" class="headerlink" title="一、HBase 是什么"></a>一、HBase 是什么</h3><p>HBase是一个分布式的、面向列的开源数据库，就像Bigtable利用了Google文件系统（File System）所提供的分布式数据存储一样，HBase在Hadoop之上提供了类似于Bigtable的能力。HBase是Apache的Hadoop项目的子项目。HBase不同于一般的关系数据库，它是一个适合于非结构化数据存储的数据库。另一个不同的是HBase基于列的而不是基于行的模式。它是一个高可靠性、高性能、面向列、可伸缩的分布式存储系统，利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群。</p>
<p><strong>HBase有如下使用场景：</strong></p>
<ul>
<li>大数据量 （100s TB级数据） 且有快速随机访问的需求。</li>
<li>例如淘宝的交易历史记录。数据量巨大无容置疑，面向普通用户的请求必然要即时响应。</li>
<li>容量的优雅扩展。</li>
<li>大数据的驱使，动态扩展系统容量的必须的。例如：webPage DB。</li>
<li>业务场景简单，不需要关系数据库中很多特性（例如交叉列、交叉表，事务，连接等等）。</li>
<li>优化方面：合理设计rowkey。因为hbase的查询用rowkey是最高效的，也几乎的唯一生产环境可行的方式。所以把你的查询请求转换为查询rowkey的请求吧。</li>
</ul>
<h3 id="二、HBase-该可用集群架构"><a href="#二、HBase-该可用集群架构" class="headerlink" title="二、HBase 该可用集群架构"></a>二、HBase 该可用集群架构</h3><p>由于我们是在已有的Hadoop可用集群基础上来搭建的，所以我们将<code>HMaster</code>分别部署在hadoop集群的<code>master1</code>和<code>master2</code>节点上，这样就能保证HBase的高可用性，放置单节点问题。将<code>RegionServer</code>部署在三个<code>slaver</code>节点上，分别是：<code>slaver1</code>、<code>slaver2</code>、<code>slaver3</code>。并且使用<code>zookeeper</code>做故障自动切换管理。</p>
<p><img src="http://img0.tuicool.com/FNJNvmm.png!web" alt="architecture"></p>
<h3 id="二、HBase-部署"><a href="#二、HBase-部署" class="headerlink" title="二、HBase 部署"></a>二、HBase 部署</h3><p>首先从官网下载：hbase-1.2.3-bin.tar.gz，下载链接为：<a href="http://apache.osuosl.org/hbase/stable/" target="_blank" rel="external">Click Me</a> 。然后上传到<code>master1</code>这个节点上。</p>
<h4 id="§-基础准备"><a href="#§-基础准备" class="headerlink" title="§ 基础准备"></a>§ 基础准备</h4><p>1、解压并重命名为<code>hbase</code>:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"># tar -axvf hbase-1.2.3-bin.tar.gz -C /opt</div><div class="line">// 重命名</div><div class="line"># mv hbase-1.2.3 hbase</div></pre></td></tr></table></figure></p>
<p>2、配置hbase的环境变量<code>/etc/profile</code>:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">// 修改配置文件</div><div class="line"># sudo vi /etc/profile</div><div class="line"></div><div class="line">// 在最后下添加</div><div class="line">export HBASE_HOME=/opt/hbase</div><div class="line">export PATH=$PATH:$HBASE_HOME/bin</div><div class="line"></div><div class="line">// 刷新配置文件</div><div class="line"># source /etc/profile</div></pre></td></tr></table></figure></p>
<h4 id="§-修改hadoop配置文件，共3个"><a href="#§-修改hadoop配置文件，共3个" class="headerlink" title="§ 修改hadoop配置文件，共3个"></a>§ 修改hadoop配置文件，共3个</h4><p>1、HBase的所有配置文件都放在<code>/hbase/conf/</code>目录下，修改<code>hbase-env.sh</code>，将文件中的export JAVA_HOME=${JAVA_HOME}写成我们自己jdk的绝对路径：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"></div><div class="line"># The java implementation to use.  Java 1.7+ required.</div><div class="line">export JAVA_HOME=/opt/jdk8</div><div class="line"></div><div class="line"></div><div class="line"># Tell HBase whether it should manage it&apos;s own instance of Zookeeper or not.</div><div class="line">export HBASE_MANAGES_ZK=true</div></pre></td></tr></table></figure></p>
<p>2、修改<code>hbase-site.xml</code>文件，在<configuration></configuration>中间加入如下内容：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div></pre></td><td class="code"><pre><div class="line">&lt;configuration&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;!--这里注意了，这里的ns1用的是hadoop集群中hdfs的命名空间（namespace）！--&gt;</div><div class="line">    &lt;name&gt;hbase.rootdir&lt;/name&gt;</div><div class="line">    &lt;value&gt;hdfs://ns1/hbase&lt;/value&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;name&gt;hbase.master&lt;/name&gt;</div><div class="line">    &lt;!--这里注意了，只需端口即可，不必再写主机名称了！--&gt;</div><div class="line">    &lt;value&gt;60000&lt;/value&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;name&gt;hbase.cluster.distributed&lt;/name&gt;</div><div class="line">    &lt;value&gt;true&lt;/value&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;!--可以不写端口号，只写主机名称，因为后面又配置端口号：2181--&gt;</div><div class="line">    &lt;name&gt;hbase.zookeeper.quorum&lt;/name&gt;</div><div class="line">    &lt;value&gt;slaver1,slaver2,slaver3&lt;/value&gt;</div><div class="line">    &lt;description&gt;The directory shared by RegionServers.&lt;/description&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;name&gt;hbase.zookeeper.property.dataDir&lt;/name&gt;</div><div class="line">    &lt;value&gt;/opt/zookeeper/data&lt;/value&gt;</div><div class="line">    &lt;description&gt;Property from ZooKeeper config zoo.cfg. The directory where the snapshot is stored.&lt;/description&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;name&gt;hbase.zookeeper.property.clientPort&lt;/name&gt;</div><div class="line">    &lt;value&gt;2181&lt;/value&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">       &lt;!--默认HMaster HTTP访问端口--&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;name&gt;hbase.master.info.port&lt;/name&gt;</div><div class="line">    &lt;value&gt;16010&lt;/value&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">       &lt;!--默认HRegionServer HTTP访问端口--&gt;</div><div class="line">  &lt;property&gt;</div><div class="line">    &lt;name&gt;hbase.regionserver.info.port&lt;/name&gt;</div><div class="line">    &lt;value&gt;16030&lt;/value&gt;</div><div class="line">  &lt;/property&gt;</div><div class="line">&lt;/configuration&gt;</div></pre></td></tr></table></figure>
<p>3、修改<code>regionservers</code>文件，加入所有需要加入HBase集群中的从节点：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">slaver1</div><div class="line">slaver2</div><div class="line">slaver3</div><div class="line">~                                                                                                                                                                                            </div><div class="line">~</div></pre></td></tr></table></figure></p>
<h4 id="§-将配置好的文件分发到其余各个节点"><a href="#§-将配置好的文件分发到其余各个节点" class="headerlink" title="§ 将配置好的文件分发到其余各个节点"></a>§ 将配置好的文件分发到其余各个节点</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"># cd /opt</div><div class="line"># scp -r ./hbase master2:/opt</div><div class="line"># scp -r ./hbase slaver1:/opt</div><div class="line"># scp -r ./hbase slaver2:/opt</div><div class="line"># scp -r ./hbase slaver3:/opt</div></pre></td></tr></table></figure>
<h4 id="§-启动HBase集群"><a href="#§-启动HBase集群" class="headerlink" title="§ 启动HBase集群"></a>§ 启动HBase集群</h4><p>在启动HBase之前，必须先启动<code>zookeeper</code>集群和<code>hadoop</code>集群。<br>1、在<code>master1</code>上面，运行以下命令，如果没有配置好hbase的环境变量，可以到<code>hbase/bin</code>目录下执行 ./start-hbase.sh：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"># start-hbase.sh</div></pre></td></tr></table></figure></p>
<p>2、在<code>master2</code>上，单独启动一个<code>HMaster</code>进程：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"># hbase-daemon.sh start master</div></pre></td></tr></table></figure></p>
<blockquote>
<p><strong>NOTE:</strong></p>
<ul>
<li>中间的<code>start</code>参数换成<code>stop</code>就成了停止指定进程的命令。</li>
</ul>
</blockquote>
<p>3、HBase集群停止命令，在<code>master1</code>上运行：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"># stop-hbase.sh</div></pre></td></tr></table></figure></p>
<p>4、验证已经正常启动：<br>在各个节点运行<code>jps</code>命令可以看到一下进程，其中<code>HMaster</code>和<code>HRegionServer</code>为HBase的相关进程：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line">// master1上运行的进程，前面的数字对应的进程的pid号</div><div class="line">3376 HMaster</div><div class="line">977 ResourceManager</div><div class="line">32756 DFSZKFailoverController</div><div class="line">3657 Jps</div><div class="line">522 NameNode</div><div class="line"></div><div class="line">// master2上运行的进程，前面的数字对应的进程的pid号</div><div class="line">30995 Jps</div><div class="line">28164 NameNode</div><div class="line">28502 ResourceManager</div><div class="line">30344 HMaster</div><div class="line">28059 DFSZKFailoverController</div><div class="line"></div><div class="line">// slaver1上运行的进程，前面的数字对应的进程的pid号</div><div class="line">13520 DataNode</div><div class="line">13367 JournalNode</div><div class="line">14488 HRegionServer</div><div class="line">13690 NodeManager</div><div class="line">14762 Jps</div><div class="line">4523 QuorumPeerMain</div><div class="line"></div><div class="line">// slaver2上运行的进程，前面的数字对应的进程的pid号</div><div class="line">21744 DataNode</div><div class="line">21591 JournalNode</div><div class="line">13450 QuorumPeerMain</div><div class="line">21915 NodeManager</div><div class="line">22972 Jps</div><div class="line">22686 HRegionServer</div><div class="line"></div><div class="line">// slaver3上运行的进程，前面的数字对应的进程的pid号</div><div class="line">22898 DataNode</div><div class="line">22744 JournalNode</div><div class="line">23848 HRegionServer</div><div class="line">24105 Jps</div><div class="line">17210 QuorumPeerMain</div><div class="line">23069 NodeManager</div></pre></td></tr></table></figure></p>
<p>5、通过hadoop的web页面，查看是否异常，以及高可用是否正常运行：</p>
<p>在浏览器中输入：<a href="http://master1:16010，其中如果本地hosts中没有建立相应的主机名与IP的映射关系，将master1换成相应的IP，显示如下：" target="_blank" rel="external">http://master1:16010，其中如果本地hosts中没有建立相应的主机名与IP的映射关系，将master1换成相应的IP，显示如下：</a></p>
<p><img src="http://img.blog.csdn.net/20161017234127072" alt="hbaseHA"></p>
<p>在浏览器中输入：<a href="http://master2:16010，其中如果本地hosts中没有建立相应的主机名与IP的映射关系，将master2换成相应的IP，显示如下：" target="_blank" rel="external">http://master2:16010，其中如果本地hosts中没有建立相应的主机名与IP的映射关系，将master2换成相应的IP，显示如下：</a></p>
<p><img src="http://img.blog.csdn.net/20161017234225172" alt="hbaseHA"></p>
<p><strong>由以上两张图可以看出，目前<code>master1</code>处于<code>active</code>状态，<code>master2</code>处于<code>standby</code>状态，说明HBase的HA已成功建立。</strong></p>
<h3 id="三、总结"><a href="#三、总结" class="headerlink" title="三、总结"></a>三、总结</h3><p>总的来说，HBase高可用集群的搭建还是相当的简单的。但有时候需要注意一下这个问题：如果HBase启动过程中显示不能够正常搜索HDFS的<code>namespace</code>或者不能解析HDFS路径，可以将<code>/opt/hadoop/etc/hadoop</code>下的<code>core-site.xml</code> 和<code>hdfs-site.xml</code>拷到<code>/opt/hbase/conf/</code>下，一般可以解决问题。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div></div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/images/jok.png" alt="小马 WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
    </div>
  </div>


      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/HBase/" rel="tag"># HBase</a>
          
            <a href="/tags/Hadoop/" rel="tag"># Hadoop</a>
          
            <a href="/tags/高可用/" rel="tag"># 高可用</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/10/10/Hadoop-2-7-3-高可用（HA）集群部署/" rel="next" title="Hadoop 2.7.3 高可用（HA）集群部署">
                <i class="fa fa-chevron-left"></i> Hadoop 2.7.3 高可用（HA）集群部署
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/12/10/数据库和数据仓库的区别/" rel="prev" title="数据库和数据仓库的区别">
                数据库和数据仓库的区别 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar1.jpg"
               alt="小马" />
          <p class="site-author-name" itemprop="name">小马</p>
           
              <p class="site-description motion-element" itemprop="description">假装不正经</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">2</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hanbert" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/BertHan" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#一、HBase-是什么"><span class="nav-number">1.</span> <span class="nav-text">一、HBase 是什么</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#二、HBase-该可用集群架构"><span class="nav-number">2.</span> <span class="nav-text">二、HBase 该可用集群架构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#二、HBase-部署"><span class="nav-number">3.</span> <span class="nav-text">二、HBase 部署</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#§-基础准备"><span class="nav-number">3.1.</span> <span class="nav-text">§ 基础准备</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#§-修改hadoop配置文件，共3个"><span class="nav-number">3.2.</span> <span class="nav-text">§ 修改hadoop配置文件，共3个</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#§-将配置好的文件分发到其余各个节点"><span class="nav-number">3.3.</span> <span class="nav-text">§ 将配置好的文件分发到其余各个节点</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#§-启动HBase集群"><span class="nav-number">3.4.</span> <span class="nav-text">§ 启动HBase集群</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#三、总结"><span class="nav-number">4.</span> <span class="nav-text">三、总结</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2016 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">小马</span>
</div>


<div class="powered-by">
   <a class="theme-link" href="https://www.hanbert.cn"> </a> 小马专属
</div>

<div class="theme-info">
  博客 -
  <a class="theme-link" href="https://www.hanbert.cn">
    记录我的生活
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  







  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  




	





  
    
    <script>
      var cloudTieConfig = {
        url: document.location.href, 
        sourceId: "",
        productKey: "a112af18c95445c591096a909c4fb62c",
        target: "cloud-tie-wrapper"
      };
    </script>
    <script src="https://img1.ws.126.net/f2e/tie/yun/sdk/loader.js"></script>
  










  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PON7x61Hu1UYOgywYUN55ig8-gzGzoHsz", "1bzugjkBEuXCThr7Cro7lz6l");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  
  <!-- 背景动画 -->
  <div id="particles-js"></div>
  <script type="text/javascript" src="/js/src/particle.js"></script>
  <!-- <script src="js/app.js"></script> -->
  
</body>
</html>
